home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / pyshared / AppInstall / DialogProprietary.py < prev    next >
Encoding:
Python Source  |  2009-03-31  |  2.5 KB  |  74 lines

  1. # (c) 2005 Canonical, GPL
  2.  
  3. from SimpleGladeApp import SimpleGladeApp
  4. import gtk
  5. import gobject
  6. import os
  7. from gettext import gettext as _
  8. import gettext
  9. from BrowserView import GtkHtml2BrowserView as BrowserView
  10.  
  11. class DialogProprietary(SimpleGladeApp):
  12.  
  13.     def __init__(self, datadir, parent, item):
  14.         SimpleGladeApp.__init__(self,
  15.                                 path=datadir+"/gnome-app-install.glade",
  16.                                 root="dialog_proprietary",
  17.                                 domain="gnome-app-install")
  18.         # Create the text of the dialog
  19.         if item.isv:
  20.             vendor = item.isv
  21.         else:
  22.             vendor = item.channel
  23.         header = _("Enable the installation of software "
  24.                    "from %s?") % vendor
  25.         body = _("%s is provided by a third party vendor.") % item.name
  26.         internet = _("You need a working internet connection to continue.")
  27.         msg = "<b><big>%s</big></b>\n\n%s\n\n%s" % (header, body, internet)
  28.  
  29.         self.dialog_proprietary.set_transient_for(parent)
  30.         self.dialog_proprietary.realize()
  31.         self.dialog_proprietary.window.set_functions(gtk.gdk.FUNC_MOVE)
  32.         self.label_proprietary.set_markup(msg)
  33.         self.item = item
  34.         self.button_add_channel.set_label(_("_Enable"))
  35.  
  36.     def run(self):
  37.         if self.item.licenseUri:
  38.             msg = self.label_proprietary.get_label()
  39.             msg += "\n\n"
  40.             msg += _("The application comes with the following license "
  41.                      "terms and conditions. Click on the "
  42.                      "'Enable' button to accept them:")
  43.             self.label_proprietary.set_markup(msg)
  44.             self.tooltips = gtk.Tooltips()
  45.             self.tooltips.set_tip(self.button_add_channel, \
  46.                                   _("Accept the license terms and install "\
  47.                                     "the software"))
  48.             self.browser.show()
  49.             self.browser.loadUri(self.item.licenseUri)
  50.         else:
  51.             self.browser.hide()
  52.         self.button_add_channel.grab_default()
  53.         return self.dialog_proprietary.run()
  54.  
  55.     def hide(self):
  56.         self.dialog_proprietary.hide()
  57.  
  58.     def create_proprietary_browser_view(self, s1, s2, i1, i2):
  59.         #print "create_custom_browser_view()"
  60.         self.browser = BrowserView()
  61.         return self.browser
  62.  
  63. if __name__ == "__main__":
  64.     import sys
  65.  
  66.     class Item(object):
  67.         pass
  68.     
  69.     item = Item()
  70.     item.licenseUri = sys.argv[1]
  71.     item.channel = sys.argv[1]
  72.     dia = DialogProprietary("../data/", None, item)
  73.     dia.run()
  74.